package com.cuit.bean;

import lombok.Data;

import java.util.concurrent.atomic.AtomicBoolean;
import java.util.concurrent.atomic.AtomicInteger;

@Data
public class CurrentServiceState {
    private AtomicBoolean hasDegrade = new AtomicBoolean(false);
    private AtomicBoolean vip = new AtomicBoolean(true);
    private AtomicInteger successCount = new AtomicInteger(0);
    private AtomicInteger errorCount = new AtomicInteger(0);

    public double calcServiceSuccessRate(){
        Integer count = errorCount.get() + successCount.get();
        if (count == 0){
            return 0;
        }
        return successCount.get() / (errorCount.get() + successCount.get());
    }

}
